package com.yh.zz_hlj.modules.adatper;

import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.TextView;

import com.yh.zz_hlj.R;
import com.yh.zz_hlj.modules.bean.CKComp;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * @author imyar
 * @date 2015年12月2日
 */
public class RKksAdapter extends ListBaseAdapter<CKComp> {

    static class ViewHolder {
        @InjectView(R.id.tv_ywy)
        TextView tv_ywy;
        @InjectView(R.id.checkBox)
        CheckBox checkBox;
        @InjectView(R.id.tv_khname)
        TextView tv_khname;
        @InjectView(R.id.tv_title)
        TextView title;
        @InjectView(R.id.tv_description)
        TextView description;
        @InjectView(R.id.tv_time)
        TextView time;
        @InjectView(R.id.iv_statue)
        ImageView iv_statue;

        public ViewHolder(View view) {
            ButterKnife.inject(this, view);
        }
    }

    @Override
    protected View getRealView(final int position, View convertView, ViewGroup parent) {
        ViewHolder vh = null;
        if (convertView == null || convertView.getTag() == null) {
            convertView = getLayoutInflater(parent.getContext()).inflate(
                    R.layout.list_cell_news, null);
            vh = new ViewHolder(convertView);
            convertView.setTag(vh);
        } else {
            vh = (ViewHolder) convertView.getTag();
        }

        CKComp blog = mDatas.get(position);
        vh.title.setText(blog.getItemDN());
//        if (blog.getFwgtype()){
//            vh.checkBox.setVisibility(View.GONE);
//        }else {
//            vh.checkBox.setVisibility(View.VISIBLE);
//            vh.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
//                @Override
//                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//                    mDatas.get(position).setFwgtype(isChecked);
//                }
//            });
//        }
//        vh.tv_index.setText(position+"");
//        vh.description.setText(blog.getGYName());
//        vh.tv_ywy.setText("宽:"+blog.getFzkuan()+"  高:"+blog.getFzgao());
//        String time=blog.getFhbdate();
//        if (!StringUtils.isEmpty(time)){
//            if (time.indexOf(".")>-1) {
//                vh.time.setText(StringUtils.friendly_time(time.replace("T", " ").substring(0, time.indexOf("."))));
//            }else {
//                vh.time.setText(StringUtils.friendly_time(time.replace("T", " ")));
//            }
//        }else {
//            String time1=blog.getFplanendDate();
//            if (!StringUtils.isEmpty(time1)) {
//                if (time1.indexOf(".") > -1) {
//                    vh.time.setText(StringUtils.friendly_time(time1.replace("T", " ").substring(0, time1.indexOf("."))));
//                } else {
//                    vh.time.setText(StringUtils.friendly_time(time1.replace("T", " ")));
//                }
//            }else {
//                vh.time.setVisibility(View.GONE);
//            }
//        }
        return convertView;
    }
}
